﻿using System;
using System.Collections;
using System.Collections.Generic;
using System.Linq;
using System.Web;
using System.Web.UI;
using System.Web.UI.WebControls;
using System.Data;

namespace Web.manager
{
    public partial class sysmodule : PageBase
    {
        protected void Page_Load(object sender, EventArgs e)
        {
            SetDivePage(ref GridView1, ref GV);
            if (!IsPostBack)
            {
                QueryData();
            }
        }

        public override void QueryData()
        {
            DataSet ds = PhoneBook.Manage.sysModule.list();
            //绑定数据集
            GVDataBind(ref GridView1, ref GV, ds);
        }

        public void GridView1_RowCommand(object sender, GridViewCommandEventArgs e)
        {
            switch (e.CommandName)
            {
                case "del":
                    string moduleid = e.CommandArgument.ToString();

                    Hashtable sysModule = PhoneBook.Manage.sysModule.get(moduleid);
                    AddLog("删除了模块：{0}({1})", sysModule["modulename"], moduleid);

                    PhoneBook.Manage.sysModule.del(moduleid);
                    Helper.ShowMessage(u_message, controls.UCMessageType.success, "删除成功");
                    
                    QueryData();
                    break;
                default:
                    break;
            }
        }

        public void GridView1_RowDataBound(object sender, GridViewRowEventArgs e)
        {
            if (e.Row.RowType == DataControlRowType.DataRow)
            {
                string parentid = ((DataRowView)e.Row.DataItem).Row["parentid"].ToString();
                if (string.IsNullOrEmpty(parentid))
                {
                    e.Row.Cells[1].Font.Bold = true;
                }
                else
                {
                    e.Row.Cells[1].Text = "┕" + e.Row.Cells[1].Text;
                }
            }
        }
    }
}